package com.aoyy.service;

import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.aoyy.model.Topic;
import com.aoyy.dao.TopicDao;
import com.aoyy.util.Page;
/**===========================================================================================
 * Topic service <code>TopicService</code>
 * @see com.aoyy.dao.TopicService
 * @author this author
 * @date 2017-08-14
 * =========================================================================================== */
@Service
public class TopicService {
	@Autowired
	private TopicDao topicDao;
	
	public void setTopicDao(TopicDao topicDao) {
		this.topicDao = topicDao;
	}
	
	public TopicDao getTopicDao() {
		return topicDao;
	}
	
	// Query topics by boardId
	public List<Topic> queryTopicsByBoardId(Integer boardId) {
	    return topicDao.queryTopicsByBoardId(boardId);	
	}
	
	// @see com.aoyy.dao.TopicDao
	public Page pagedQuery(Integer pageNo, Integer pageSize, Integer boardId) {
		return topicDao.pagedQuery(pageNo, pageSize, boardId);
	}
	
	// @see com.aoyy.dao.TopicDao
	public Topic queryTopicByTopicId(Integer topicId) {
		return topicDao.queryTopicByTopicId(topicId);
	}
	
	// @see com.aoyy.dao.TopicDao
	public void updateTopicDigest(Integer topicId, Integer checked) {
		topicDao.updateTopicDigest(topicId, checked);
	}
	
	// Add topic
	public void save(Topic topic) {
		topicDao.save(topic);
	}
     
	// Delete topic 
	public void delete(Topic topic) {
		topicDao.delete(topic);
	}
	
	// Update topic
	public void update(Topic topic) {
		topicDao.update(topic);
	}
	
	// @see com.aoyy.dao.TopicDao
	public void updateTopicViewsByTopicId(Integer topicId) {
		topicDao.updateTopicViewsByTopicId(topicId);
	}
	
}
